#ifndef _DSWGPIOCTRL_H
#define _DSWGPIOCTRL_H

#include "base.h"
#include <dswgpio/ioctl_gpio.h>

#define GPIO_DRV "/dev/dswgpio"

class CDswgpioctrl
{
public:
	CDswgpioctrl(LPST_ENV_T pEnv);
	virtual ~CDswgpioctrl();
public:
	static void cbIntCallback(int num);
	void HDPower(bool bPoweroff);
	void GPRSPowerOff(bool bPoweroff);
	EN_POWER_TYPE GetPowerType(){return m_nCurPWRTtype;};
private:
	void CreateReadTask();
	void IntCallback();
	void InitGpio(int nfd);
	static void cbTimerTask(int fd, short events, void* ctx){((CDswgpioctrl*)ctx)->OnTimer(fd, events);};
	void OnTimer(int fd, short events);
private:
	LPST_ENV_T m_pEnv;
	int m_nfd;
	time_t m_nLastFangchai, m_nLastLevel;
	EN_POWER_TYPE m_nOldPWRType, m_nCurPWRTtype;
	bool m_bOldLowPWR;

	timer_param_t m_nIntTask;

	bool m_bHasInt;
	pthread_mutex_t m_bHasInt_lock;
};

#endif

